package com.example.demo.business.controller.v1;

import com.example.demo.business.bean.dto.CollectionDto;
import com.example.demo.business.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartRequest;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/v1/user")
public class UserController {

    @Autowired
    private UserService userService;

    //注册 source
    @PostMapping("/register")
    public Object loginAndRegister(String deviceToken,String source,@RequestParam(defaultValue = "0") String promeCode){
        return userService.register(deviceToken, source,promeCode);
    }

    //收藏
    @PostMapping("/collection")
    public Object collectionMovie(CollectionDto collectionDto){
        return userService.collectionMovie(collectionDto);
    }

    //取消收藏
    @GetMapping("/collection/cancer")
    public Object collectionMovieRemove(CollectionDto collectionDto){
        return userService.removeCollection(collectionDto);
    }

    //查看收藏
    @GetMapping("/collection/list")
    public Object collectionMovieList(String token,int type){
        return userService.collectionList(type,token);
    }

    //查看收藏
    @GetMapping("/collection/list/all")
    public Object collectionMovieListAll(String token){
        return userService.collectionListAll(token);
    }

    //绑定手机 type 1是绑定 2是解绑 3是找回 4是重置安全码
    @PostMapping("/tel")
    public Object setUserTel(String token,String tel ,String verifyCode,@RequestParam(defaultValue = "1") int type){
        return userService.editUserTel(token,tel,verifyCode,type);
    }

    //发送验证码
    @GetMapping("/verifyCode")
    public Object sendVerifyCode(String phone){
        return "";
    }

    //通过token获取用户信息
    @GetMapping("/info")
    public Object getUserInfo(String token){
        return userService.getUserInfo(token);
    }

    //设置安全码
    @PostMapping("/secCode")
    public Object setSecCode(String token,String code){
        return userService.setSecCode(token, code);
    }

    //修改安全码
    @PostMapping("/secCode/edit")
    public Object editSecCode(String token,String oldCode,String newCode){
        return userService.editSecCode(token, oldCode,newCode);
    }
    //验证安全码是否正确
    @GetMapping("/secCode/verify")
    public Object verifySecCode(String token,String code){
        return userService.verifySecCode(token, code);
    }

    //上传番号求片信息
    @PostMapping("/mash")
    public Object setMash(String token,String code){
        return userService.setMash(token, code);
    }

    //查看番号求片信息
    @GetMapping("/mash")
    public Object setMash(String token){
        return userService.getMash(token);
    }

    //兑换码兑换
    @GetMapping("/cdk")
    public Object useCDK(String token){
        return "";
    }

    //问题反馈
    @PostMapping("/feedback")
    public Object problemFeedback(String token, int type , String detail, HttpServletRequest multipartRequest){
        return userService.problemFeedback(token, type, detail, multipartRequest);
    }

    //问题反馈 ios
    @PostMapping("/feedback/base64")
    public Object problemFeedback(String token,int type ,String detail,String img){
        return userService.problemFeedbackBase64(token, type, detail, img);
    }

    //查看问题反馈
    @GetMapping("/feedback")
    public Object getProblemFeedback(String token){
        return userService.getProblemFeedback(token);
    }


    //获取推广链接
    @GetMapping("/promote/links")
    public Object getProblemLinks(String token){
        return userService.getProblemLinks(token);
    }


}
